<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>患者查报告</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css?time=20190312" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/patient/reportSearch.css?time=20190505"/>
		<link rel="stylesheet" href="../../css/sale/orderDetail.css" />
		<link rel="stylesheet" type="text/css" href="../../css/doctor/project/common.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/patient/preview.css"/>
		<script src="../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
		
	</style>
	<body>
		<div id="report">
			<div class="mui-content" id="reportSearch" v-cloak >
			    <div class="wrap">
			    	<div class="contain">
			    		<p>报告单自助查询</p>
			    		<div class="panel">
 			    			<ul>
			    				<li class="mui-table-view-cell"><span>患者姓名：</span><input type="text" v-model="patientName" placeholder="请输入患者姓名"/></li>
			    				<li class="mui-table-view-cell" v-if="isPhone">
			    					<span>检验条码：</span>
			    					<input type="text"  v-model="barCode" placeholder="请输入检验条码" />
			    					<span class="switchPhone" @tap="switchPhone"><i class="iconfont icon-zhuanhuan"></i>手机号查询</span>
			    				</li>
			    				<li class="mui-table-view-cell" v-if="!isPhone">
			    					<span>手机号码：</span>
			    					<input type="text"  v-model="phone" placeholder="请输入手机号码" maxlength="11" />
			    					<span class="switchPhone" @tap="switchPhone"><i class="iconfont icon-zhuanhuan"></i>条形码查询</span>
			    				</li>
			    				<li class="mui-table-view-cell" v-if="!isPhone">
			    					<span>验证码：</span>
			    					<input type="text"  v-model="smsCode" placeholder="请输入验证码" />
			    					<button class="getCode" @tap='getCode' :disabled="vCodeBtn">{{codeText}}</button>
			    				</li>
			    			</ul>
			    			<button @tap="search">查询</button>
			    		</div>
			    	</div>
			    </div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/mui.zoom.js?time=654323"></script>
		<script src="../../js/mui.previewimage.js?time=333"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/cmms.js?time=222"></script>
		<script>
			mui.previewImage();
//			mui.plusReady(function() {})
			var first = new Vue({
				el:"#report",
				data:{
					barCode:'',
					btnShow:false,
					vCodeBtn: false, //获取验证码按钮
					codeText: '获取验证码',
					patientName:'',
					phone:'',
					hasPhone:false,
					hasBarcode:false,
					isPhone:false,
					smsCode:''
				},
				computed: {
		        	newVoList: function() {
		        		for(let i of res.voList){
		        			return (this.i.consumablesName || "").split(",")
						}
		        	}
		       },
				mounted(){
//					var vConsole = new VConsole();
					this.getUrl();
//					this.readReport();
				},
				watch:{
					phone:function(){
						this.barCode.replace(/\s*/g,"");
					},
					barCode:function(){
						this.phone.replace(/\s*/g,"");
					},
				},
				methods:{
					/*获取微信端URI后的code和state*/
					getUrl(){
						let _this=this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();  
//						console.log(url);
					   	if (url.indexOf("?") != -1) {   
					      var str = url.substr(1);  
//					      console.log(str);
					      strs = str.split("&");  
					      for(var i = 0; i < strs.length; i ++) {   
					         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
					      } 
					   	}   
					   	console.log(theRequest);
					   	_this.state = theRequest.state;
					},
					//验证码
					getCode: function() {
						let _this = this;
						let regPhone= /^1[3456789]\d{9}$/;
						if(_this.phone == '') {
							mui.alert('请输入手机号');
							return false;
						}else if(!(regPhone.test(_this.phone))){
							mui.alert('手机号格式有误，请检查');
							return false;
						}else{
							AT.muiAjax('/common/common/sendMessage', 'post', {
								mobile: _this.phone
							}, function(realData) {
								console.log(realData);
							});
							let time = 60;
							_this.vCodeBtn = true;
							_this.timer = setInterval(function() {
								_this.codeText = '重新获取(' + time + ')S';
								time--;
								if(time < 0) {
									clearInterval(_this.timer);
									_this.vCodeBtn = false;
									_this.codeText = '获取验证码';
								}
							}, 1000)
						}
						
					},
					search(){
						let _this = this;
//						_this.isShow = true;
						if(_this.patientName==''){
							mui.alert('患者姓名不能为空！');
							return false;
						}else{
							let regPhone= /^1[3456789]\d{9}$/;
							switch(_this.isPhone){
								case true:
									if(_this.barCode.trim()==''){
										mui.alert('检验条码不能为空！');
									}else{
										window.location.href = "order.html?name="+_this.patientName.trim()+"&barCode="+_this.barCode.trim()+"&phone="+"&smsCode=";
									}
									break;
								case false:
									if(_this.phone.trim()==''){
										mui.alert('手机号码不能为空！');
									}else if(!(regPhone.test(_this.phone))){
										mui.alert('手机号格式有误，请检查');
										return false;
									}else if(_this.smsCode.trim()==''){
										mui.alert('验证码不能为空！');
									}else{
										window.location.href = "order.html?name="+_this.patientName.trim()+"&phone="+_this.phone.trim()+"&barCode="+"&smsCode="+_this.smsCode.trim();
									}
									break;
							}
						}
					},
					switchPhone(){
						if(this.isPhone){
							this.isPhone=false;
//							this.phone = '';
						}else{
							this.isPhone=true;
//							this.bacCode = '';
						}
					}
				}
			});
		</script>
	</body>
</html>